#!/bin/bash

#
# packager Startup script for Vod Packager
#
#

start() {
    echo "Starting Queue Pull Daemon"
    python QPull.py start
    echo "Starting Queue Import Daemon"
    python QImport.py  start
    echo "Starting Queue Checker Daemon"
    python QChecker.py start
    echo "Starting Queue Pre-Packager Daemon"
    python QPrePackager.py start
    echo "Starting Queue Packager Daemon"
    python QPackager.py start
    echo "Starting Vod Packager Api Server"
    python VPApiServer.py start
    echo "Starting Queue Purge Daemon"
    python QPurge.py start
}


stop() {
    echo "Stopping Quueu Pull Daemon"
    python QPull.py stop
    echo "Stopping Queue Import Daemon"
    python QImport.py stop
    echo "Stopping Queue Checker Daemon"
    python QChecker.py stop
    echo "Stopping Queue Pre-Packager Daemon"
    python QPrePackager.py stop
    echo "Stopping Queue Packager Daemon"
    python QPackager.py stop
    echo "Stopping Vod Packager Api Server"
    python VPApiServer.py stop
    echo "Stopping Queue Purge Daemon"
    python QPurge.py stop
}


status() {
    echo -n "Queue Pull Status: "
    python QPull.py status
    echo -n "Queue Import Status: "
    python QImport.py status
    echo -n "Queue Checker Status: "
    python QChecker.py status
    echo -n "Queue Pre-Packager Status: "
    python QPrePackager.py status
    echo -n "Queue Packager Status: "
    python QPackager.py status
    echo -n "Vod Packager Api Server Status: "
    python VPApiServer.py status
    echo -n "Queue Purge Status: "
    python QPurge.py status
}


echo "Vod Packager Starter"

case "$1" in
    start)
	start
	;;
    stop)
	stop
	;;
    status)
	status
	;;
    restart)
	stop
	start
	;;
    *)
	echo "Usage: packager {start|stop|restart|status}"
esac
exit